<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

class WxNotice extends Model
{
	use HasDateTimeFormatter;
//    use SoftDeletes;

    protected $table = 'wx_notice';

    public function user()
    {
        return $this->hasOne(WxUser::class, "id", "user_id");
    }

    public function addNotice($uid,$title,$content,$noticeType,$posts_id = '',$order_id = '')
    {

        $this->user_id = $uid;
        $this->posts_id = $posts_id;
        $this->order_id = $order_id;
        $this->title = $title;
        $this->content = $content;
        $this->is_read = 0;
        $this->notice_type = $noticeType;// 类型(0系统通知，1活动通知，2帖子点赞通知，3帖子收藏通知，4帖子评论通知，5评论点赞通知)
        $this->save();
    }

}
